package com.doit.mr.day01;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;

import java.net.URI;
import java.net.URISyntaxException;

/**
 * @DATE 2021/12/8/11:12
 * @Author MDK
 * @Version 2021.2.2
 *
 *      关于配置文件  javaAPI 和 shellCMD 操作hdfs文件系统
 *         1)shell中hdfs-site.xml
 *         2)java代码  可以配置在resource文件中的 hdfs-site.xml
 *         3)可以用Configuration  代码设置
 **/
public class C09_Conf {
    public static void main(String[] args) throws Exception {
        URI uri = new URI("hdfs://linux01:8020");
        Configuration conf = new Configuration();

        //conf自定义的参数  修改副本个数  name value
        conf.set("dfs.replication", "5");
        //修改物理切块大小
        conf.set("dfs.blocksize","64M");
        String user = "root";
        FileSystem fs = FileSystem.newInstance(uri, conf, user);

        Path srcPath = new Path("d://aaa//2.txt");
        Path destPath = new Path("/2.txt");
        fs.copyFromLocalFile(srcPath, destPath);
        fs.close();
    }
}
